/*   1:    */ package com.atomikos.icatch.imp;
/*   2:    */ 
/*   3:    */ import com.atomikos.finitestates.FSMEnterEvent;
/*   4:    */ import com.atomikos.finitestates.FSMEnterListener;
/*   5:    */ import com.atomikos.icatch.Synchronization;
/*   6:    */ import com.atomikos.icatch.TxState;
/*   7:    */ import com.atomikos.icatch.system.Configuration;
/*   8:    */ 
/*   9:    */ class SynchToFSM
/*  10:    */   implements FSMEnterListener
/*  11:    */ {
/*  12:    */   private Synchronization synch_;
/*  13:    */   private boolean aftercompletion_;
/*  14:    */   private boolean termination_;
/*  15:    */   
/*  16:    */   SynchToFSM(Synchronization s)
/*  17:    */   {
/*  18: 55 */     this.synch_ = s;
/*  19: 56 */     this.aftercompletion_ = false;
/*  20: 57 */     this.termination_ = false;
/*  21:    */   }
/*  22:    */   
/*  23:    */   private void doAfterCompletion(TxState state)
/*  24:    */   {
/*  25:    */     try
/*  26:    */     {
/*  27: 63 */       this.synch_.afterCompletion(state);
/*  28:    */     }
/*  29:    */     catch (RuntimeException e)
/*  30:    */     {
/*  31: 66 */       Configuration.logWarning("Error during afterCompletion", e);
/*  32:    */     }
/*  33:    */   }
/*  34:    */   
/*  35:    */   public void entered(FSMEnterEvent e)
/*  36:    */   {
/*  37: 73 */     if (e != null) {
/*  38: 74 */       if ((e.getState().equals(TxState.COMMITTING)) && (!this.aftercompletion_))
/*  39:    */       {
/*  40: 76 */         doAfterCompletion(TxState.COMMITTING);
/*  41: 77 */         this.aftercompletion_ = true;
/*  42:    */       }
/*  43: 78 */       else if ((e.getState().equals(TxState.ABORTING)) && (!this.aftercompletion_))
/*  44:    */       {
/*  45: 80 */         doAfterCompletion(TxState.ABORTING);
/*  46: 81 */         this.aftercompletion_ = true;
/*  47:    */       }
/*  48: 82 */       else if ((e.getState().equals(TxState.TERMINATED)) && (!this.termination_))
/*  49:    */       {
/*  50: 84 */         doAfterCompletion(TxState.TERMINATED);
/*  51: 85 */         this.aftercompletion_ = true;
/*  52: 86 */         this.termination_ = true;
/*  53:    */       }
/*  54: 87 */       else if ((e.getState().equals(TxState.HEUR_MIXED)) && (!this.termination_))
/*  55:    */       {
/*  56: 89 */         doAfterCompletion(TxState.HEUR_MIXED);
/*  57: 90 */         this.termination_ = true;
/*  58:    */       }
/*  59: 92 */       else if ((e.getState().equals(TxState.HEUR_ABORTED)) && (!this.termination_))
/*  60:    */       {
/*  61: 94 */         doAfterCompletion(TxState.HEUR_ABORTED);
/*  62: 95 */         this.termination_ = true;
/*  63:    */       }
/*  64: 96 */       else if ((e.getState().equals(TxState.HEUR_HAZARD)) && (!this.termination_))
/*  65:    */       {
/*  66: 98 */         doAfterCompletion(TxState.HEUR_HAZARD);
/*  67: 99 */         this.termination_ = true;
/*  68:    */       }
/*  69:100 */       else if ((e.getState().equals(TxState.HEUR_COMMITTED)) && (!this.termination_))
/*  70:    */       {
/*  71:102 */         doAfterCompletion(TxState.HEUR_COMMITTED);
/*  72:103 */         this.termination_ = true;
/*  73:    */       }
/*  74:    */     }
/*  75:    */   }
/*  76:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions\3.7.0\transactions-3.7.0.jar
 * Qualified Name:     com.atomikos.icatch.imp.SynchToFSM
 * JD-Core Version:    0.7.0.1
 */